<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $failException = true;

    protected $rule = [
        'mobile' => 'require|mobile|unique:user,mobile,0,id,delete_time null'
    ];

    /**
     * 验证提示信息
     * @var array
     */
    protected $message = [];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add' => [],
    ];

    /**
     * 验证场景-编辑资料
     */
    public function edit(): User
    {
        return $this->only(['username', 'nickname', 'password', 'email'])
            ->remove('password', 'require');
    }

    public function __construct()
    {
        $this->field   = [
            'mobile'    => ('Mobile'),
        ];
        parent::__construct();
    }
}